//go:build wireinject

// wire依赖注入
package startup

import (
	"basic-go/webook/internal/repository"
	"basic-go/webook/internal/repository/cache"
	"basic-go/webook/internal/repository/dao"
	"basic-go/webook/internal/service"
	"basic-go/webook/internal/web"
	"basic-go/webook/ioc"

	"github.com/gin-gonic/gin"
	"github.com/google/wire"
)

func InitWebServer() *gin.Engine {
	wire.Build(
		// 第三方依赖
		ioc.InitRedis, ioc.InitDB,
		// DAO
		dao.NewUserDAO,
		// cache
		cache.NewCodeCache, cache.NewUserCache,
		// repository
		repository.NewCachedUserRepository,
		repository.NewCachedCodeRepository,
		// service
		ioc.InitSMSService,
		service.NewUserService,
		service.NewCodeService,
		// handler
		web.NewUserHandler,
		// web
		ioc.InitGinMiddlewares,
		ioc.InitWebServer,
	)
	return gin.Default()
}
